package com.rw.test.config.exception;

import com.rw.engine.ip.exception.IpInterceptorException;
import com.rw.test.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常捕获
 */
@ControllerAdvice
public class IpExceptionHandler {
    @ResponseBody
    @ExceptionHandler(IpInterceptorException.class)
    public ResultVO<String> ipExceptionHandler(IpInterceptorException exception) {
        return new ResultVO<>(1, "很抱歉，您的IP已被禁止访问！", exception.getIp());
    }
}
